package chapter12;

import chapter9.DynamicArray;

import java.util.AbstractList;
import java.util.Collection;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/2/20 11:05
 */
public class MyList<E> extends AbstractList<E> {
    private DynamicArray<E> dynamicArray;

    public MyList() {
        this.dynamicArray = new DynamicArray<>();
    }

    public MyList(Collection<? extends E> collection) {
        this();
        addAll(collection);
    }

    @Override
    public E get(int index) {
        return dynamicArray.get(index);
    }

    @Override
    public int size() {
        return dynamicArray.size();
    }

    @Override
    public E set(int index, E element) {
        return dynamicArray.set(index, element);
    }

    @Override
    public void add(int index, E element) {
        dynamicArray.add(index, element);
    }

    @Override
    public E remove(int index) {
        return dynamicArray.remove(index);
    }
}
